<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * 积分商品模型
 */
class Goods extends Model
{

    public $timestamps = false;

    protected $table = 'goods';

    protected $primaryKey = 'goods_id';

    protected $fillable = [
        'goods_id',
        'name', //商品名称
        'goods_number', //商品编号
        'photo', //商品主图
        'introduce', //商品简介
        'closed', //1上架 2下架
        'status', //0待审核1审核通过2审核不通过
        'note', //审核备注
        'price', //市场价
        'postage', //邮费：0为免邮，大于0为对应邮费
        'delivery_type', //配送方式：1为快递免邮
        'sort', //排序
        'details', //商品详情
        'details_type', //详情类型 1纯文本 2纯图片
        'is_delete', //1删除0未删除
        'create_time', //添加时间
        'admin_id', //审核人
        'photo_oss',
    ];

    protected $casts = ['photo'];

    public function getPhotoAttribute($value)
    {
        return \App\Library\HandleFile::handleFilePath($value, $this->photo_oss);
    }

    //关联积分秒杀表
    public function integral_kill()
    {
        return $this->hasOne('App\\Models\\IntegralKill', 'goods_id', 'goods_id');
    }
}
